package com.cn.aam.checaiduo.minterface;

import android.content.Context;
import android.content.Intent;

import com.cn.aam.checaiduo.AppData;
import com.cn.aam.checaiduo.ui.me.MessageListActivity;
import com.orhanobut.logger.Logger;
import com.umeng.message.UmengNotificationClickHandler;
import com.umeng.message.entity.UMessage;

/**
 * 时间：2017/3/14
 * 描述：
 */

public class UmengNotificationClickListener extends UmengNotificationClickHandler {

    private Context getContext() {
        return AppData.getContext();
    }

    @Override
    public void launchApp(Context context, UMessage msg) {
        goToMessageList();
        Logger.e("launchApp " + msg.toString());
    }

    @Override
    public void openUrl(Context context, UMessage msg) {
        Logger.e("openUrl " + msg.toString());
        goToMessageList();

    }

    @Override
    public void openActivity(Context context, UMessage msg) {
//        super.openActivity(context, msg);
        goToMessageList();
        Logger.e("openActivity " + msg.toString());
    }

    @Override
    public void dealWithCustomAction(Context context, final UMessage msg) {
        goToMessageList();
        Logger.e("dealWithCustomAction " + msg.toString());

    }

    @Override
    public void dismissNotification(Context context, UMessage uMessage) {
        super.dismissNotification(context, uMessage);
        Logger.e("dismissNotification " + uMessage.toString());
    }

    private void goToMessageList(){
        Intent intent=MessageListActivity.newInstance(getContext());
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        getContext().startActivity(intent);
    }
}
